﻿<RibbonWindow x:Class="KGEditor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="clr-namespace:System;assembly=mscorlib"
        xmlns:rw="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ribbon"
        xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        xmlns:src="clr-namespace:KGEditor"
        Title="KGEditor" Width="1280" Height="800" WindowState="Maximized"
        Loaded="MainWindowLoaded" Unloaded="MainWindowUnloaded">
    <Window.Resources>
        <ObjectDataProvider x:Key="FindCriteria" ObjectType="{x:Type src:MainWindow}" />
        <src:RadioButtonCheckedConverter x:Key="RadioButtonCheckedConverter" />
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Ribbon Grid.Row="0">
            <RibbonTab x:Name="model" Header="Model">
                <RibbonGroup>
                    <RibbonButton LargeImageSource="Images\Open.png" Label="Open" Click="OpenClick"/>
                    <RibbonButton LargeImageSource="Images\Save.png" x:Name="save" Label="Save" Click="SaveClick"/>
                    <RibbonButton LargeImageSource="Images\SaveAs.png" x:Name="save_as" Label="Save as" Click="SaveAsClick"/>
                </RibbonGroup>
                <RibbonGroup>
                    <RibbonButton LargeImageSource="Images\Undo.png" x:Name="undo" Label="Undo" Click="UndoClick"/>
                    <RibbonButton LargeImageSource="Images\Redo.png" x:Name="redo" Label="Redo" Click="RedoClick"/>
                </RibbonGroup>
                <RibbonGroup Header="Entities">
                    <RibbonButton LargeImageSource="Images\Mesh.png" Label="Add Model" Click="AddModelClick"/>
                    <RibbonMenuButton LargeImageSource="Images/Light.png" Label="Add Light">
                        <RibbonMenuItem Header="Ambient" Click="AddAmbientLightClick"/>
                        <RibbonMenuItem Header="Directional" Click="AddDirectionalLightClick"/>
                        <RibbonMenuItem Header="Point" Click="AddPointLightClick"/>
                        <RibbonMenuItem Header="Spot" Click="AddSpotLightClick"/>
                    </RibbonMenuButton>
                    <RibbonButton LargeImageSource="Images\Camera.png" Label="Add Camera" Click="AddCameraClick"/>
                    <RibbonButton LargeImageSource="Images\Remove.png" Label="Remove" Click="RemoveEntityClick"/>
                </RibbonGroup>
                <RibbonGroup Header="Control Mode">
                    <RibbonRadioButton LargeImageSource="Images\Selection.png" Label="Selection" Name="selection" IsChecked="{Binding ControlModeProperty, Converter={StaticResource RadioButtonCheckedConverter}, ConverterParameter={x:Static src:ControlModeEnum.CM_EntitySelection}, Mode=TwoWay}" GroupName="ControlModeGroup" KeyTip="Q"/>
                    <RibbonRadioButton LargeImageSource="Images\Translation.png" Label="Translation" Name="translation" IsChecked="{Binding ControlModeProperty, Converter={StaticResource RadioButtonCheckedConverter}, ConverterParameter={x:Static src:ControlModeEnum.CM_EntityTranslation}, Mode=TwoWay}" GroupName="ControlModeGroup" KeyTip="W"/>
                    <RibbonRadioButton LargeImageSource="Images\Rotation.png" Label="Rotation" Name="rotation" IsChecked="{Binding ControlModeProperty, Converter={StaticResource RadioButtonCheckedConverter}, ConverterParameter={x:Static src:ControlModeEnum.CM_EntityRotation}, Mode=TwoWay}" GroupName="ControlModeGroup" KeyTip="E"/>
                    <RibbonRadioButton LargeImageSource="Images\Scaling.png" Label="Scaling" Name="scaling" IsChecked="{Binding ControlModeProperty, Converter={StaticResource RadioButtonCheckedConverter}, ConverterParameter={x:Static src:ControlModeEnum.CM_EntityScaling}, Mode=TwoWay}" GroupName="ControlModeGroup" KeyTip="R"/>
                </RibbonGroup>
            </RibbonTab>
        </Ribbon>
        
        <Border Grid.Row="1">
            <xcad:DockingManager x:Name="_dockingManager" AllowMixedOrientation="True" BorderBrush="Black" BorderThickness="1">
                <xcad:LayoutRoot x:Name="_layoutRoot">
                    <xcad:LayoutPanel Orientation="Horizontal">
                        <xcad:LayoutAnchorablePane DockWidth="300">
                            <xcad:LayoutAnchorable ContentId="SceneTree" Title="Scene Tree" CanHide="True" CanClose="False" AutoHideWidth="300">
                                <TreeView ItemsSource="{Binding SceneRoot}">
                                    <TreeView.ItemContainerStyle>
                                        <Style TargetType="{x:Type TreeViewItem}">
                                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                            <Setter Property="FontWeight" Value="Normal" />
                                            <Style.Triggers>
                                                <Trigger Property="IsSelected" Value="True">
                                                    <Setter Property="FontWeight" Value="Bold" />
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TreeView.ItemContainerStyle>

                                    <TreeView.ItemTemplate>
                                        <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                                            <TextBlock Text="{Binding Name}" />
                                        </HierarchicalDataTemplate>
                                    </TreeView.ItemTemplate>
                                </TreeView>
                            </xcad:LayoutAnchorable>
                        </xcad:LayoutAnchorablePane>
                        <xcad:LayoutDocumentPane>
                            <xcad:LayoutDocument ContentId="document1" x:Name="doc1" Title="Editor" CanClose="False">
                                <Label Name="editor_bg" SizeChanged="EditorWindowSizeChanged" Padding="0" AllowDrop="True" DragEnter="EditorBGDragEnter" Drop="EditorBGDrop">
                                    <WindowsFormsHost Name="editor_frame" KeyUp="EditorKeyUp">
                                        <wf:Panel x:Name="editor_wnd" MouseDown="EditorMouseDown" MouseUp="EditorMouseUp" MouseMove="EditorMouseMove"/>
                                    </WindowsFormsHost>
                                </Label>
                            </xcad:LayoutDocument>
                        </xcad:LayoutDocumentPane>
                        <xcad:LayoutAnchorablePane DockWidth="300">
                            <xcad:LayoutAnchorable ContentId="properties" Title="Properties" CanHide="False" CanClose="False" AutoHideWidth="300">
                                <xctk:PropertyGrid x:Name="properties" NameColumnWidth="110" PropertyValueChanged="PropertyGridValueChanged"/>
                            </xcad:LayoutAnchorable>
                        </xcad:LayoutAnchorablePane>
                    </xcad:LayoutPanel>
                </xcad:LayoutRoot>
            </xcad:DockingManager>
        </Border>
        
        <StatusBar HorizontalAlignment="Stretch" Height="30" Margin="0,0,0,0" Grid.Row="2" VerticalAlignment="Bottom" Width="auto"/>
    </Grid>
</RibbonWindow>
